<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script src="js/bootstrap.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<h1><a href="<c:url context='${pageContext.request.contextPath}' value='/users'/>">查看所有用户</a>
</h1>
<table class="table table-striped table-responsive">
    <tr>
        <td>ID</td>
        <td>姓名</td>
        <td>密码</td>
        <td>性别</td>
        <td>出生日期</td>
        <td>注册日期</td>
    </tr>
    <c:forEach items="${requestScope.pageInfo.list}" var="user">
        <tr>
            <td>${user.id}</td>
            <td>${user.name}</td>
            <td>${user.password}</td>
            <td>${user.sex}</td>
            <td>${user.birthday}</td>
            <td><fmt:formatDate value="${user.registTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
        </tr>
    </c:forEach>
</table>
<div class="container">
    <div class="row">
        <div class="text-center">
            <ul class="pagination">
                <c:if test="${requestScope.pageInfo.pageNum>1}">
                    <li>
                        <a href="${pageContext.request.contextPath}/users?pageNum=${requestScope.pageInfo.pageNum-1}"><<</a>
                    </li>
                </c:if>
                <c:forEach begin="1" end="${requestScope.pageInfo.pages}" var="p">
                    <li><a href="<c:url context='${pageContext.request.contextPath}' value='/users?pageNum=${p}'/>">${p}</a></li>
                </c:forEach>
                <c:if test="${requestScope.pageInfo.pageNum<requestScope.pageInfo.pages}">
                    <li>
                        <a href="${pageContext.request.contextPath}/users?pageNum=${requestScope.pageInfo.pageNum+1}">>></a>
                    </li>
                </c:if>
            </ul>
        </div>
    </div>
</div>
</body>
</html>
